########################################################################
# snippets.sh - GMOULD snippets functions library
# Copyright (C) 2013 Mohamad Afifi Omar <afifio@gmail.com>
#
# These comments cannot be remove or edited and should remain intact
# because this file comments is an extension to the GPL3 license.
# This software file is covered by GPL version 3 license.
# Please see the LICENSE and gpl3.txt or gpl3.htm in doc directory
# for the license agreement, if its not exist, write to the 
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
# Modification below this line is allowed
########################################################################
# Extra credits to:
#
########################################################################
# Notes:
# Put notes to other future developer/contributor here
# You can add your codes here and call it from the toolbar action
# See ToolbargMouldMarkup.tlb how to apply it using the <action>
########################################################################
#Log INFO "Loading snippets..."
########################################################################
# Snip_AAA_TEMPLATE - Snippets
# Usage: Snip_AAA_TEMPLATE filename
#	Snip_AAA_TEMPLATE filename  			# call in script
#   '"$(Snip_AAA_TEMPLATE filename)"' 	# call in xml
########################################################################
<<\SNIPPET

<span color="MidnightBlue" font-family="Sans" size="xx-large" variant="smallcaps"><big><b><i><u>Chapter</u></i></b></big></span>
<span color="DarkSlateBlue" font-family="Sans" size="x-large"><big><b><i>Title</i></b></big></span>
<span color="SlateBlue3" font-family="Sans" size="x-large"><big><b><i>Section</i></b></big></span>
<span color="SlateBlue2" font-family="Sans"><big><b><i>SubSection</i></b></big></span>
<span size="large" color="DarkGreen"><b><tt>echo code</tt></b></span>
<span size="large" color="DarkOrange"><b><tt>echo code standout</tt></b></span>
<span font-family="Sans" ><sup><i>pic title</i></sup></span>
<span color="SlateBlue2" font-family="Sans"><b>emphasis</b></span>
<span  font-family="Sans" ><b><i>emphasis</i></b></span>
<span color="Firebrick" font-family="Sans" >warning</span>
pop
Normal
SNIPPET
########################################################################
function Snip_AAA_TEMPLATE()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
Template code here
SNIPPET
fi
}; export -f Snip_AAA_TEMPLATE

########################################################################
function Snip_MARKUPTITLE()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<span color="MidnightBlue" font-family="Sans" size="xx-large" variant="smallcaps"><big><b><i><u>Chapter</u></i></b></big></span>
SNIPPET
fi
}; export -f Snip_MARKUPTITLE
########################################################################
function Snip_MARKUPCODE()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<span size="large" color="DarkGreen"><b><tt>CODE</tt></b></span>
SNIPPET
fi
}; export -f Snip_MARKUPCODE

########################################################################
function Snip_NEW_COMPONENT()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET

########################################################################
# gWhatever - Do whatever
# Usage: gWhatever registryvarname
########################################################################
function gWhatever()
{
#gInitVar registryvarname registryvarsubname defaultvalue
local label=`gInitVar "$1" "label" 'Default Button'`
local variable=`gInitVar "$1" "variable" 'v'$RANDOM`
local icon=`gInitVar "$1" "icon" 'gtk-index'`
local sensitive=`gInitVar "$1" "sensitive" 'true'`
local signalclicked=`gInitVar "$1" "signalclicked" 'gActionNothing'`
local component='
<hbox>
	<button>
		<label>'$label'</label>
		<variable>'$variable'</variable>
		<input file stock="'$icon'"></input>
		<sensitive>'$sensitive'</sensitive>
		<action signal="clicked">'$signalclicked'</action>
	</button>
</hbox>'
echo $component
};export -f gWhatever
SNIPPET
fi
}; export -f Snip_NEW_COMPONENT

########################################################################
function Snip_XML_WINDOW()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<window tag_attr="value"...>
	widget...
	<variable>varname</variable>
	<action signal="type">activity</action>...
</window>
SNIPPET
fi
}; export -f Snip_XML_WINDOW

########################################################################
function Snip_XML_VSEPARATOR()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<vseparator tag_attr="value"...>
</vseparator>
SNIPPET
fi
}; export -f Snip_XML_VSEPARATOR
########################################################################
function Snip_XML_VSCALE()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<vscale tag_attr="value"...>
	<default>value</default>
	<variable>varname</variable>
	<input>command</input>
	<input file>filename</input>
	<sensitive>state</sensitive>
	<action>activity</action>...
	<action signal="type">activity</action>...
	<action type="function">parameter</action>...
	<item>data</item>...
	<output file>filename</output>
</vscale>
SNIPPET
fi
}; export -f Snip_XML_VSCALE
########################################################################
function Snip_XML_VBOX()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<vbox tag_attr="value"...>
	widget...
</vbox>
SNIPPET
fi
}; export -f Snip_XML_VBOX
########################################################################
function Snip_XML_TREE()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<tree tag_attr="value"...>
	<label>text</label>
	<variable>varname</variable>
	<height>value</height>
	<width>value</width>
	<input>command</input>...
	<input icon-column="index">command</input>...
	<input stock-column="index">command</input>...
	<input file>filename</input>...
	<input file icon-column="index">filename</input>...
	<input file stock-column="index">filename</input>...
	<sensitive>state</sensitive>
	<action>activity</action>...
	<action signal="type">activity</action>...
	<action type="function">parameter</action>...
	<item>data</item>...
	<item icon-name="image">data</item>...
	<item stock-id="gtk-image">data</item>...
</tree>
SNIPPET
fi
}; export -f Snip_XML_TREE
########################################################################
function Snip_XML_TOGGLEBUTTON()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<togglebutton tag_attr="value"...>
	<label>text</label>
	<default>state</default>
	<variable>varname</variable>
	<height>value</height>
	<width>value</width>
	<input>command</input>
	<input file>filename</input>
	<input file icon="image"></input>
	<input file stock="gtk-image"></input>
	<sensitive>state</sensitive>
	<action>activity</action>...
	<action signal="type">activity</action>...
	<action type="function">parameter</action>...
</togglebutton>
SNIPPET
fi
}; export -f Snip_XML_TOGGLEBUTTON
########################################################################
function Snip_XML_TIMER()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<timer tag_attr="value"...>
	<variable>varname</variable>
	<sensitive>state</sensitive>
	<action>activity</action>...
	<action signal="type">activity</action>...
	<action type="function">parameter</action>...
</timer>
SNIPPET
fi
}; export -f Snip_XML_TIMER
########################################################################
function Snip_XML_TEXT()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<text tag_attr="value"...>
	<label>text</label>
	<variable>varname</variable>
	<input>command</input>
	<input file>filename</input>
	<sensitive>state</sensitive>
	<action signal="type">activity</action>...
</text>
SNIPPET
fi
}; export -f Snip_XML_TEXT
########################################################################
function Snip_XML_TABLE()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<table>
	<label>text</label>
	<variable>varname</variable>
	<height>value</height>
	<width>value</width>
	<input>command</input>...
	<sensitive>state</sensitive>
	<action>activity</action>...
	<action type="function">parameter</action>...
	<item>data</item>...
</table>
SNIPPET
fi
}; export -f Snip_XML_TABLE
########################################################################
function Snip_XML_STATUSBAR()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<statusbar tag_attr="value"...>
	<label>text</label>
	<default>text</default>
	<variable>varname</variable>
	<input>command</input>
	<input file>filename</input>
	<sensitive>state</sensitive>
	<action signal="type">activity</action>...
	<output file>filename</output>
</statusbar>
SNIPPET
fi
}; export -f Snip_XML_STATUSBAR
########################################################################
function Snip_XML_SPINBUTTON()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<spinbutton tag_attr="value"...>
	<default>value</default>
	<variable>varname</variable>
	<input>command</input>
	<input file>filename</input>
	<sensitive>state</sensitive>
	<action>activity</action>...
	<action signal="type">activity</action>...
	<action type="function">parameter</action>...
	<output file>filename</output>
</spinbutton>
SNIPPET
fi
}; export -f Snip_XML_SPINBUTTON
########################################################################
function Snip_XML_RADIOBUTTON()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<radiobutton tag_attr="value"...>
	<label>text</label>
	<default>state</default>
	<variable>varname</variable>
	<sensitive>state</sensitive>
	<action>activity</action>...
	<action signal="type">activity</action>...
	<action type="function">parameter</action>...
</radiobutton>
SNIPPET
fi
}; export -f Snip_XML_RADIOBUTTON
########################################################################
function Snip_XML_PROGRESSBAR()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<progressbar tag_attr="value"...>
	<label>text</label>
	<variable>varname</variable>
	<input>command</input>
	<action>activity</action>...
	<action type="function">parameter</action>...
</progressbar>
SNIPPET
fi
}; export -f Snip_XML_PROGRESSBAR
########################################################################
function Snip_XML_PIXMAP()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<pixmap tag_attr="value"...>
	<variable>varname</variable>
	<height>value</height>
	<width>value</width>
	<input file>filename</input>
	<input file icon="image"></input>
	<input file stock="gtk-image"></input>
	<sensitive>state</sensitive>
</pixmap>
SNIPPET
fi
}; export -f Snip_XML_PIXMAP
########################################################################
function Snip_XML_NOTEBOOK()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<notebook tag_attr="value"...>
	widget...
	<variable>varname</variable>
	<input>command</input>
	<input file>filename</input>
	<sensitive>state</sensitive>
	<output file>filename</output>
</notebook>
SNIPPET
fi
}; export -f Snip_XML_NOTEBOOK
########################################################################
function Snip_XML_MENU()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<menu tag_attr="value"...>
	menu...
	menuitem...
	<label>text</label>
	<variable>varname</variable>
	<height>value</height>
	<width>value</width>
	<input>command</input>
	<sensitive>state</sensitive>
	<action>activity</action>...
	<action signal="type">activity</action>...
	<action type="function">parameter</action>...
</menu>
SNIPPET
fi
}; export -f Snip_XML_MENU
########################################################################
function Snip_XML_MENUITEM()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<menuitem tag_attr="value"...>
	<label>text</label>
	<variable>varname</variable>
	<height>value</height>
	<width>value</width>
	<input>command</input>
	<input file>filename</input>
	<sensitive>state</sensitive>
	<action>activity</action>...
	<action signal="type">activity</action>...
	<action type="function">parameter</action>...
	<output file>filename</output>
</menuitem>
SNIPPET
fi
}; export -f Snip_XML_MENUITEM
########################################################################
function Snip_XML_MENUITEMSEPARATOR()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
	<menuitemseparator></menuitemseparator>
SNIPPET
fi
}; export -f Snip_XML_MENUITEMSEPARATOR
########################################################################
function Snip_XML_MENUBAR()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<menubar>
	menu...
</menubar>
SNIPPET
fi
}; export -f Snip_XML_MENUBAR
########################################################################
function Snip_XML_LIST()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<list tag_attr="value"...>
	<variable>varname</variable>
	<height>value</height>
	<width>value</width>
	<input>command</input>...
	<sensitive>state</sensitive>
	<action>activity</action>...
	<action type="function">parameter</action>...
	<item>data</item>...
</list>
SNIPPET
fi
}; export -f Snip_XML_LIST
########################################################################
function Snip_XML_HSEPARATOR()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<hseparator tag_attr="value"...>
</hseparator>
SNIPPET
fi
}; export -f Snip_XML_HSEPARATOR
########################################################################
function Snip_XML_HSCALE()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<hscale tag_attr="value"...>
	<default>value</default>
	<variable>varname</variable>
	<input>command</input>
	<input file>filename</input>
	<sensitive>state</sensitive>
	<action>activity</action>...
	<action signal="type">activity</action>...
	<action type="function">parameter</action>...
	<item>data</item>...
	<output file>filename</output>
</hscale>
SNIPPET
fi
}; export -f Snip_XML_HSCALE
########################################################################
function Snip_XML_HBOX()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<hbox tag_attr="value"...>
	widget...
</hbox>
SNIPPET
fi
}; export -f Snip_XML_HBOX

########################################################################
function Snip_XML_FRAME()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<frame label>
	widget...
</frame>
SNIPPET
fi
}; export -f Snip_XML_FRAME

########################################################################
function Snip_XML_ENTRY()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<entry tag_attr="value"...>
	<default>text</default>
	<variable>varname</variable>
	<height>value</height>
	<width>value</width>
	<input>command</input>
	<input file>filename</input>
	<sensitive>state</sensitive>
	<action>activity</action>...
	<action signal="type">activity</action>...
	<action type="function">parameter</action>...
	<output file>filename</output>
</entry>
SNIPPET
fi
}; export -f Snip_XML_ENTRY
########################################################################
function Snip_XML_EDIT()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<edit tag_attr="value"...>
	<default>state</default>
	<variable>varname</variable>
	<height>value</height>
	<width>value</width>
	<input file>filename</input>
	<sensitive>state</sensitive>
	<action signal="type">activity</action>...
	<output file>filename</output>
</edit>
SNIPPET
fi
}; export -f Snip_XML_EDIT
########################################################################
function Snip_XML_COMBOBOXTEXT()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<comboboxtext tag_attr="value"...>
	<default>text</default>
	<variable>varname</variable>
	<input>command</input>...
	<input file>filename</input>...
	<sensitive>state</sensitive>
	<action>activity</action>...
	<action signal="type">activity</action>...
	<action type="function">parameter</action>...
	<item>data</item>...
	<output file>filename</output>
</comboboxtext>
SNIPPET
fi
}; export -f Snip_XML_COMBOBOXTEXT
########################################################################
function Snip_XML_COMBOBOXENTRY()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<comboboxentry tag_attr="value"...>
	<default>text</default>
	<variable>varname</variable>
	<input>command</input>...
	<input file>filename</input>...
	<sensitive>state</sensitive>
	<action>activity</action>...
	<action signal="type">activity</action>...
	<action type="function">parameter</action>...
	<item>data</item>...
	<output file>filename</output>
</comboboxentry>
SNIPPET
fi
}; export -f Snip_XML_COMBOBOXENTRY
########################################################################
function Snip_XML_COLORBUTTON()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<colorbutton tag_attr="value"...>
	<default>data</default>
	<variable>varname</variable>
	<input>command</input>
	<input file>filename</input>
	<sensitive>state</sensitive>
	<action>activity</action>...
	<action signal="type">activity</action>...
	<action type="function">parameter</action>...
	<output file>filename</output>
</colorbutton>
SNIPPET
fi
}; export -f Snip_XML_COLORBUTTON
########################################################################
function Snip_XML_CHECKBOX()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<checkbox tag_attr="value"...>
	<label>text</label>
	<default>state</default>
	<variable>varname</variable>
	<input>command</input>
	<sensitive>state</sensitive>
	<action>activity</action>...
	<action signal="type">activity</action>...
	<action type="function">parameter</action>...
</checkbox>
SNIPPET
fi
}; export -f Snip_XML_CHECKBOX
########################################################################
function Snip_XML_BUTTON()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<button yes no ok cancel help tag_attr="value"...>
	<label>text</label>
	<variable>varname</variable>
	<height>value</height>
	<width>value</width>
	<input file>filename</input>
	<input file icon="image"></input>
	<input file stock="gtk-image"></input>
	<sensitive>state</sensitive>
	<action>activity</action>...
	<action signal="type">activity</action>...
	<action type="function">parameter</action>...
</button>
SNIPPET
fi
}; export -f Snip_XML_BUTTON
########################################################################
# Snip_SCRIPT_CASE - Snippets
# Usage: Snip_SCRIPT_CASE filename
#	Snip_SCRIPT_CASE filename  			# call in script
#   '"$(Snip_SCRIPT_CASE filename)"' 	# call in xml
########################################################################
function Snip_SCRIPT_CASE()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
case "$1" in
	[[:lower:]]	)
		echo "Lowercase letter"
		;;
	[[:upper:]]	)
		echo "Uppercase letter"
		;;
	[0-9]	) 
		echo "Digit"
		;;
	*	) 
		echo "Other"
		;;
esac
SNIPPET
fi
}; export -f Snip_SCRIPT_CASE
########################################################################
# Snip_SCRIPT_IFELIF - Snippets
# Usage: Snip_SCRIPT_IFELIF filename
#	Snip_SCRIPT_IFELIF filename  			# call in script
#   '"$(Snip_SCRIPT_IFELIF filename)"' 	# call in xml
########################################################################
function Snip_SCRIPT_IFELIF()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
if [ "$#" -eq 0 ]
then
	echo "No parameter"
	exit 65
elif  [ "$#" -gt 2 ]
	echo "Too many parameter"
	exit 65
fi
SNIPPET
fi
}; export -f Snip_SCRIPT_IFELIF
########################################################################
# Snip_SCRIPT_IFELSE - Snippets
# Usage: Snip_SCRIPT_IFELSE filename
#	Snip_SCRIPT_IFELSE filename  			# call in script
#   '"$(Snip_SCRIPT_IFELSE filename)"' 	# call in xml
########################################################################
function Snip_SCRIPT_IFELSE()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
if [ -z "$1" ]
then
	echo "No parameter"
else
	echo "$1"
fi
SNIPPET
fi
}; export -f Snip_SCRIPT_IFELSE
########################################################################
# Snip_SCRIPT_IFTHEN - Snippets
# Usage: Snip_SCRIPT_IFTHEN filename
#	Snip_SCRIPT_IFTHEN filename  			# call in script
#   '"$(Snip_SCRIPT_IFTHEN filename)"' 	# call in xml
########################################################################
function Snip_SCRIPT_IFTHEN()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
if [ -z "$1" ]
then
	echo "No parameter"
fi
SNIPPET
fi
}; export -f Snip_SCRIPT_IFTHEN
########################################################################
# Snip_SCRIPT_MULTICOMMENT - Snippets
# Usage: Snip_SCRIPT_MULTICOMMENT filename
#	Snip_SCRIPT_MULTICOMMENT filename  			# call in script
#   '"$(Snip_SCRIPT_MULTICOMMENT filename)"' 	# call in xml
########################################################################
function Snip_SCRIPT_MULTICOMMENT()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
########################################################################
#	$2
########################################################################
SNIPPET
fi
}; export -f Snip_SCRIPT_MULTICOMMENT
########################################################################
# Snip_SCRIPT_UNTIL - Snippets
# Usage: Snip_SCRIPT_UNTIL filename
#	Snip_SCRIPT_UNTIL filename  			# call in script
#   '"$(Snip_SCRIPT_UNTIL filename)"' 	# call in xml
########################################################################
function Snip_SCRIPT_UNTIL()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
END_CONDITION="end"
until [ "$var1" = "$END_CONDITION" ]
do
	echo "Input variable #1 or ($END_CONDITION to exit)"
	read var1
	echo "variable #1 = $var1"
done
SNIPPET
fi
}; export -f Snip_SCRIPT_UNTIL
########################################################################
# Snip_SCRIPT_FOR1 - Snippets
# Usage: Snip_SCRIPT_FOR1 filename
#	Snip_SCRIPT_FOR1 filename  			# call in script
#   '"$(Snip_SCRIPT_FOR1 filename)"' 	# call in xml
########################################################################
function Snip_SCRIPT_FOR1()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
# Standard syntax.
for a in 1 2 3 4 5 6 7 8 9 10
do
	echo -n "$a "
done
SNIPPET
fi
}; export -f Snip_SCRIPT_FOR1
########################################################################
# Snip_SCRIPT_FOR2 - Snippets
# Usage: Snip_SCRIPT_FOR2 filename
#	Snip_SCRIPT_FOR2 filename  			# call in script
#   '"$(Snip_SCRIPT_FOR2 filename)"' 	# call in xml
########################################################################
function Snip_SCRIPT_FOR2()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
# C syntax.
# Double parentheses, and "LIMIT" with no "$".
# The comma can chain together operations.
LIMIT=10
for ((a=1, b=1; a <= LIMIT ; a++, b++))  
do
	echo -n "$a-$b "
done
SNIPPET
fi
}; export -f Snip_SCRIPT_FOR2

########################################################################
# Snip_SCRIPT_WHILE - Snippets
# Usage: Snip_SCRIPT_WHILE filename
#	Snip_SCRIPT_WHILE filename  			# call in script
#   '"$(Snip_SCRIPT_WHILE filename)"' 	# call in xml
########################################################################
function Snip_SCRIPT_WHILE()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
a=0
while [ "$a" -le 10 ]
	do
	echo -n "$a "
	let "a+=1"
done
SNIPPET
fi
}; export -f Snip_SCRIPT_WHILE
########################################################################
# Snip_SCRIPT_FUNCTION - Snippetsp
# Usage: Snip_SCRIPT_FUNCTION filename
#	Snip_SCRIPT_FUNCTION filename  			# call in script
#   '"$(Snip_SCRIPT_FUNCTION filename)"' 	# call in xml
########################################################################
function Snip_SCRIPT_FUNCTION()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
########################################################################
# fxfunction - Function template, copy, paste and replace fxfunction
# Usage: fxfunction param1 param2 param3
########################################################################
function fxfunction()
{
#	fxfunction param1 param2 param3  			# call in script
#   '"$(fxfunction param1 param2 param3)"' 	# call in xml
	echo 'This function is missing'
};export -f fxfunction
SNIPPET
fi
}; export -f Snip_SCRIPT_FUNCTION
########################################################################
# Snip_SCRIPT_BLOCKCOMMENT - Snippets
# Usage: Snip_SCRIPT_BLOCKCOMMENT filename
#	Snip_SCRIPT_BLOCKCOMMENT filename  			# call in script
#   '"$(Snip_SCRIPT_BLOCKCOMMENT filename)"' 	# call in xml
########################################################################
function Snip_SCRIPT_BLOCKCOMMENT()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
: <<'COMMENTBLOCK'
	Commented block, bracketed var
	should also commented out.
COMMENTBLOCK
SNIPPET
fi
}; export -f Snip_SCRIPT_BLOCKCOMMENT
########################################################################
# Snip_SCRIPT_SINGLECOMMENT - Snippets
# Usage: Snip_SCRIPT_SINGLECOMMENT filename
#	Snip_SCRIPT_SINGLECOMMENT filename  			# call in script
#   '"$(Snip_SCRIPT_SINGLECOMMENT filename)"' 	# call in xml
########################################################################
function Snip_SCRIPT_SINGLECOMMENT()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
#	$2
SNIPPET
fi
}; export -f Snip_SCRIPT_SINGLECOMMENT
########################################################################
# Snip_SCRIPT_GETOPTS - Snippets
# Usage: Snip_SCRIPT_GETOPTS filename
#	Snip_SCRIPT_GETOPTS filename  			# call in script
#   '"$(Snip_SCRIPT_GETOPTS filename)"' 	# call in xml
########################################################################
function Snip_SCRIPT_GETOPTS()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
while getopts ":ab:cd:" Option
do
	case $Option in
		a	)
			echo "Scenario #1: option -m-   [OPTIND=${OPTIND}]"
			;;
		b	)
			echo "Scenario #2: option -$ with argument \"$OPTARG\"   [OPTIND=${OPTIND}]"
			;;
		c	)
			echo "Scenario #3: option -c-   [OPTIND=${OPTIND}]"
			;;
		d	)
			echo "Scenario #4: option -d with argument \"$OPTARG\"   [OPTIND=${OPTIND}]"
			;;
		*	)
			echo "Unimplemented option chosen."
			;;   # DEFAULT
	esac
done
shift $(($OPTIND - 1))
#  $1 now references the first non option item supplied
SNIPPET
fi
}; export -f Snip_SCRIPT_GETOPTS
########################################################################
# Snip_SCRIPT_FILEHEADER - Snippets
# Usage: Snip_SCRIPT_FILEHEADER filename
#	Snip_SCRIPT_FILEHEADER filename  			# call in script
#   '"$(Snip_SCRIPT_FILEHEADER filename)"' 	# call in xml
########################################################################
function Snip_SCRIPT_FILEHEADER()
{
if [ ! -z "$1" ]
then
filename=$2
description=$3
cat >> $1 <<\SNIPPET
#!/bin/bash
########################################################################
# $filename - $description
# Copyright (C) 2013 Mohamad Afifi Omar <afifio@gmail.com>
#
# These comments cannot be remove or edited and should remain intact
# because this file comments is an extension to the GPL3 license.
# This software file is covered by GPL version 3 license.
# Please see the LICENSE and gpl3.txt or gpl3.htm in doc directory
# for the license agreement, if its not exist, write to the 
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
# Modification below this line is allowed
########################################################################
# Extra credits to:
#
########################################################################
# Notes:
# Put notes to other future developer/contributor here
#
########################################################################
Log INFO "$filename loading..."
########################################################################
# $filename - Function description
# Usage: $filename param1 param2 param3
#	$filename param1 param2 param3  			# call in script
#   '"$($filename param1 param2 param3)"' 	# call in xml
########################################################################
function $filename()
{
if [ ! -z "$1" ]
then
	echo '$filename'
fi
};export -f $filename


########################################################################
Log INFO "$filename done loading"
########################################################################
SNIPPET
fi
}; export -f Snip_SCRIPT_FILEHEADER
########################################################################
# Snip_SPAN - Snippets
# Usage: Snip_SPAN filename
#	Snip_SPAN filename  			# call in script
#   '"$(Snip_SPAN filename)"' 	# call in xml
########################################################################
function Snip_MARKUPSPAN()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<span>SPAN</span>
SNIPPET
fi
}; export -f Snip_MARKUPSPAN

function Snip_MARKUPBIG()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<big>BIG</big>
SNIPPET
fi
}; export -f Snip_MARKUPBIG

function Snip_MARKUPSMALL()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<small>SMALL</small>
SNIPPET
fi
}; export -f Snip_MARKUPSMALL

function Snip_MARKUPBOLD()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<b>BOLD</b>
SNIPPET
fi
}; export -f Snip_MARKUPBOLD

function Snip_MARKUPITALICS()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<i>ITALICS</i>
SNIPPET
fi
}; export -f Snip_MARKUPITALICS
function Snip_MARKUPUNDERLINE()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<u>UNDERLINE</u>
SNIPPET
fi
}; export -f Snip_MARKUPUNDERLINE
function Snip_MARKUPSTRIKETHROUGH()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<s>STRIKETHROUGH</s>
SNIPPET
fi
}; export -f Snip_MARKUPSTRIKETHROUGH


function Snip_MARKUPSUPERSCRIPT()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<s>SUPERSCRIPT</s>
SNIPPET
fi
}; export -f Snip_MARKUPSUPERSCRIPT


function Snip_MARKUPSUBSCRIPT()
{
if [ ! -z "$1" ]
then
cat >> $1 <<\SNIPPET
<sub>SUBSCRIPT</sub>
SNIPPET
fi
}; export -f Snip_MARKUPSUBSCRIPT
#Log INFO "Done loading snippets"
